﻿using System;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Configuration;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Tools
{
    public class ConfigReader
    {
        private NameValueCollection Infos = ConfigurationManager.AppSettings;
        public static ConfigReader Reader = new ConfigReader();
        /// <summary>
        /// 根据key获取数据文本信息
        /// </summary>
        /// <param name="key"></param>
        /// <returns></returns>
        public string this[string key]
        {
            get
            {
                if (Infos[key] != null)
                {
                    return Infos[key].Trim();
                }
                else
                {
                    return "";
                }
            }
        }
        /// <summary>
        /// 验证key值是否存在
        /// </summary>
        /// <param name="key"></param>
        /// <returns></returns>
        public bool Check(string key)
        {
            if (Infos[key] != null)
            {
                return true;
            }
            else
            {
                return false;
            }
        }
    }
}
